﻿<Window x:Class="Requestor.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:Requestor.TestApp"
        xmlns:System="clr-namespace:System;assembly=mscorlib" 
        xmlns:request="clr-namespace:Request;assembly=Request"
        Title="Отправка запросов"
        SizeToContent="Width"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize">
    <Window.Resources>
        <converters:BoolConverter x:Key="BoolConverter" />
        <ObjectDataProvider x:Key="dataFromEnum"
                            MethodName="GetValues"
                            ObjectType="{x:Type System:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="request:HttpMethod" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Vertical"
                    Margin="10"
                    Grid.Row="0">
            <StackPanel Orientation="Horizontal"
                        Margin="5">
                <TextBlock Text="URL:"
                           Width="120" />
                <TextBox Text="{Binding Url, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         Margin="10,0,0,0"
                         Width="500" />
                <Button Content="Отправить"
                        Command="{Binding SendCommand}"
                        Margin="10,0,0,0"
                        Width="200" />
            </StackPanel>
            <StackPanel Orientation="Horizontal"
                        Margin="5">
                <TextBlock Text="Тип запроса:"
                           Width="120" />
                <ComboBox ItemsSource="{Binding Source={StaticResource dataFromEnum}}"
                          SelectedItem="{Binding CurrentRequestType, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          Width="500"
                          Margin="10,0,0,0" />
                <RadioButton Content="Синхронный"
                             IsChecked="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                             Margin="10,0,0,0" />
                <RadioButton Content="Асинхронный"
                             IsChecked="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource BoolConverter}}"
                             Margin="10,0,0,0" />
            </StackPanel>
        </StackPanel>
        <StackPanel Orientation="Vertical"
                    Margin="10"
                    Grid.Row="1">
            <ListBox ItemsSource="{Binding Data, Mode=TwoWay}"
                     Margin="5"
                     Height="172" />
            <Button Content="Добавить новый параметр"
                    Margin="5"
                    Command="{Binding AddParameterCommand}" />
        </StackPanel>
        <StackPanel Orientation="Vertical"
                    Margin="10"
                    Grid.Row="2">
            <TextBlock Text="Результат:"
                       Margin="5" />
            <TextBox IsReadOnly="True"
                     Text="{Binding Result, Mode=OneWay}"
                     Margin="5"
                     Height="158" />
        </StackPanel>
    </Grid>
</Window>